<!--{include(file='head.html')}-->
<div id="wrap">
	<!--{include('left.html')}-->
	<div id="maincont">
		<b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
		<div id="main_c" >
			<form name="seaform" id="seaform" action="<!--{url('admin','cat','catitem')}-->" method="post">
				<div class="bt_bk">
					<span class="btn">
						<a href="javascript:void(0);" onclick="$.oper.refresh();return false;" class="refresh">刷新</a>
					</span>
					<select name="add" id="add" onchange="$.oper.change('add')">
						<option value="0">增加到类别</option>
						<!--{$catopt}-->
					</select>
					<select name="transfer" id="transfer" onchange="$.oper.change('transfer')">
						<option value="0">转移到类别</option>
						<!--{$catopt}-->
					</select>
					<span class="state_tip"></span>
				</div>
				<input type="hidden" value="<!--{def($pagearr['page'],1)}-->"		name="page" id="page"/>
				<input type="hidden" value="<!--{def($pagearr['pagesize'],10)}-->"	name="pagesize" id="pagesize" />
			</form>
			<!--{include_page("page.html","top")}-->
			<form name="submitform" id="submitform" action="<!--{url('admin','cat','catitemsave')}-->" method="post">
			<table class="tableStyle" border="0" cellspacing="0" cellpadding="0">
				<thead>
					<tr align="center">
						<th width="10%">
							<input type="checkbox" value="1" name="allselect" id="allselect" autocomplete="off" onclick="$.oper.selectall()"/>
						</th>
						<th width="60%" colspan="2">商品名称</th>
						<th width="30%">所属分类（点击具体分类，移除）</th>
					</tr>
				</thead>
				<tbody id="listtbody">
					<!--{foreach $items item}-->
					<tr align="center"  id="tr_<!--{$item.itemid}-->">
						<td><input type="checkbox" value="<!--{$item.itemid}-->" name="itemid[]" name="singleselect" autocomplete="off"/>
						</td>
						<td>
							<a href="<!--{url('index','item','index','itemid=$item[itemid]')}-->" target="_blank">
								<img src = "<!--{$item.itemimg}-->_50x50.jpg" width="50" height="50" onerror="this.onerror='',this.src='images/nopicture.jpg'" class="mid"/>
							</a>
						</td>
						<td align="left">
							<!--{$item.itemname}-->
						</td>
						<td>
							<!--{if $item.cat}-->
								<!--{foreach $item.cat key cat}-->
									<a href="javascript:void(0);" onclick="$.oper.delcat(<!--{$item.itemid}-->,<!--{$key}-->,this);return false;"><!--{$cat}--></a>
								<!--{/foreach}-->
							<!--{else}-->
							--
							<!--{/if}-->
						</td>
					</tr>
					<!--{/foreach}-->
				</tbody>
			</table>
				<input type="hidden" value="" name="catid" id="catid"/>
				<input type="hidden" value="" name="opertype" id="opertype"/>
			</form>
			<!--{include_page("page.html","foot")}-->
		</div>
		<b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b>
	</div>
</div>
<!--{include(file='foot.html')}-->
<script type="text/javascript">
$(function(){
	$.oper.init("<!--{url('admin','cat','catitemsave')}-->");
	$.oper.change = function(type) {
		var ele = $("#listtbody").find("input:checked");
		if(ele.length == 0) {
			jAlert("请选择需要操作的项","警告");
			return false;
		}
		var $obj = $("#"+type);
		if($obj.val() == 0) return ;
		$("#catid").val($obj.val());
		$("#opertype").val(type);
		$obj.val(0);
		this.submit();
	};
	$.oper.delcat = function(itemid,catid,obj) {
		var $obj = $(obj),$parent = $obj.parent();
		if($parent.find("a").length < 2) {
			jAlert("商品至少有一个分类","警告");
			return false;
		}
		postdata = {itemid:itemid,catid:catid,opertype:'delcat'};
		$.post(this.url,postdata,function(data){
			if(data == "success") {
				$obj.remove();
			} else {
				jAlert("发生错误,请刷新页面后重新执行该操作","警告");
			}
		});
	}
})
</script>